var _contextPath;

$(document).ready(function() {
	list();
	top.UppTabs.operator = top.getCurrentTagTitle();// 设置用户tab的标题值
});

/**
 * 查询用户列表
 */
function list() {
	_contextPath = $("#contextPath").val();
	$("#reconciliation_list").datagrid(
			{
				queryParams : {
					userId : $("#userId").val(),
					recentlyDate:$("#recentlyDate").val(),
					newDate:$("#newDate").val(),
					opStatus:$("#opStatus").val()
				},
				columns : [ [ {
					field : 'rechargeable_card_num',
					title : '用户卡号',
					width : 100,
					align : 'center'
				}, {
					field : 'rechargeable_card_credit_amount',
					title : '交易金额（元）',
					width : 100,
					align : 'center'
				}, {
					field : 'op_status',
					title : '交易方式',
					width : 100,
					align : 'center',
					formatter : function(value, row, index) {
						if (value == '0') {
							return '退款';
						} else if (value == '1') {
							return '充值';
						} else {
							return '';
						}
					}
				}, {
					field : 'rechargeable_card_credit_time',
					title : '操作时间',
					width : 100,
					align : 'center',
					formatter : function(value, row, index) {
						return (new Date(Number(value))).dateConvert();
					}						
				}, {
					field : 'recharge_type',
					title : '结算方式',
					width : 100,
					align : 'center',
					formatter : function(value, row, index) {
						if (value == '0') {
							return '网银';
						} else if (value == '1') {
							return '现金';
						} else {
							return '';
						}
					}				
				}] ],
				autoRowHeight : true,
				fitColumns : true,
				pagination : true,
				rownumbers : true,
				singleSelect : true
			});
	//汇总
	$.ajax({
        url: contextPath + '/iccard/rcreconciliation/reconciliationSum',
        dataType: "json",
        data: {
        	userId : $("#userId").val(),
			recentlyDate:$("#recentlyDate").val(),
			opStatus:$("#opStatus").val()
		},
        success: function( data ) {
        	$("#hjje").val(data.rlsum);
        	$("#total_rl_amount").text("合计："+data.rlsum+"元 ");
        }
      });
}
	window.top["reload_combocard_list"]=function(){
		$('#reconciliation_list').datagrid( "load");
	};
	function getContextPath() {
		if ("" == _contextPath) {
			_contextPath = $("#contextPath").val();
		}
		return _contextPath;
	}
	/**
	 * 搜索
	 * 
	 * @return
	 */
	function searchKey() {
		list();
	}
	
	/**
	 * 对账确认
	 */
	function enterDz(){
		uppDialog.confirm("开始确认对账？", function() {
		$.ajax({
	        url: contextPath + '/iccard/rcreconciliation/checkCountReconciliation',
	        dataType: "json",
	        data: {
	        	userId : $("#userId").val(),
				recentlyDate:$("#recentlyDate").val(),
				opStatus:$("#opStatus").val(),
				newDate:$("#newDate").val(),
				hjje:$("#hjje").val()
			},
	        success: function(data) {
	        	if(data==0){
	        		jQuery.messager.alert('提示:','对账成功');
	        		setTimeout("window.location.href=contextPath+'/iccard/rcreconciliation/rcrlist.jsp'", 3000);
	        	}else{
	        		jQuery.messager.alert('提示:','对账失败');
	        	}
	        }
	      });
		});
			
	}

